From 0533122983d2ac973453915cb1331b87d8d7fc0a Mon Sep 17 00:00:00 2001
From: Romain Naour <romain.naour@gmail.com>
Date: Sun, 28 Aug 2022 23:21:37 +0200
Subject: [PATCH] gdb: Fix native build on xtensa
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Apply a similar fix than for Alpha architecture on gdb 9:
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=7a27b85f6d9b5eea9bd1493f903158fbea4b2231

Fixes:

../../gdb/xtensa-linux-nat.c: In function ‘void fill_gregset(const regcache*, elf_greg_t (*)[128], int)’:
../../gdb/xtensa-linux-nat.c:66:17: error: ‘gdbarch_pc_regnum’ was not declared in this scope
   66 |   if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
      |                 ^~~~~~~~~~~~~~~~~
  CXX    complaints.o
../../gdb/xtensa-linux-nat.c:68:17: error: ‘gdbarch_ps_regnum’ was not declared in this scope
   68 |   if (regnum == gdbarch_ps_regnum (gdbarch) || regnum == -1)
      |                 ^~~~~~~~~~~~~~~~~
../../gdb/xtensa-linux-nat.c:71:38: error: no matching function for call to ‘gdbarch_tdep::gdbarch_tdep(gdbarch*&)’
   71 |   if (regnum == gdbarch_tdep (gdbarch)->wb_regnum || regnum == -1)
      |                                      ^
In file included from ../../gdb/xtensa-linux-nat.c:38:
../../gdb/xtensa-tdep.h:160:8: note: candidate: ‘gdbarch_tdep::gdbarch_tdep()’
  160 | struct gdbarch_tdep
      |        ^~~~~~~~~~~~
../../gdb/xtensa-tdep.h:160:8: note:   candidate expects 0 arguments, 1 provided
../../gdb/xtensa-tdep.h:160:8: note: candidate: ‘constexpr gdbarch_tdep::gdbarch_tdep(const gdbarch_tdep&)’
../../gdb/xtensa-tdep.h:160:8: note:   no known conversion for argument 1 from ‘gdbarch*’ to ‘const gdbarch_tdep&’
../../gdb/xtensa-tdep.h:160:8: note: candidate: ‘constexpr gdbarch_tdep::gdbarch_tdep(gdbarch_tdep&&)’
../../gdb/xtensa-tdep.h:160:8: note:   no known conversion for argument 1 from ‘gdbarch*’ to ‘gdbarch_tdep&&’
../../gdb/xtensa-linux-nat.c:72:49: error: no matching function for call to ‘gdbarch_tdep::gdbarch_tdep(gdbarch*&)’
   72 |     regcache->raw_collect (gdbarch_tdep (gdbarch)->wb_regnum,
      |                                                 ^

Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
 gdb/xtensa-linux-nat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
index e3da3c6a7a5..61834bc28d0 100644
--- a/gdb/xtensa-linux-nat.c
+++ b/gdb/xtensa-linux-nat.c
@@ -36,6 +36,7 @@
 
 #include "gregset.h"
 #include "xtensa-tdep.h"
+#include "gdbarch.h"
 
 /* Defines ps_err_e, struct ps_prochandle.  */
 #include "gdb_proc_service.h"
-- 
2.43.0

